#!/bin/bash 
# @configure_input@
export PATH=@RCC_BIN_PATH@:${PATH}
export LOUD=true
if [[ "$1" == "-q" ]] ; then
    export LOUD=false
    shift
fi
for f in $* ; do 
    base=`basename $f`
    base=${base/%.[rR]/}     # remove .r or .R at end
    if [[ $f =~ "\.[rR]$" ]]
    then bin=$base
    else bin=$base.bin
    fi
    echo --- $f --- &&
    if $LOUD ; then echo compiling $f with rcc... ; fi &&
    rcc $f -o ./$base.c &&
    if $LOUD ; then echo compiling $base.c with rcc-cc... ; fi &&
    rcc-cc -O2 -o ./$bin -g ./$base.c &&
    if $LOUD ; then echo running $bin with rcc-run... ; fi &&
    rcc-run ./$bin
done
